package demo.icanci.pattern.singleton;

/**
 * 单例设计模式 饿汉式
 *
 * @author icanci
 * @date Created in 2021/02/06 00:18
 * @version 1.0
 */
public class StarvingSingleton {
    /**
     * 初始化
     */
    private static final StarvingSingleton INSTANCE = new StarvingSingleton();

    /**
     * 私有化构造
     */
    private StarvingSingleton() {

    }

    /**
     * 获取单例对象
     * @return 返回单例对象
     */
    public static StarvingSingleton getInstance() {
        return INSTANCE;
    }

    public static void main(String[] args) {
        System.out.println(StarvingSingleton.getInstance() == StarvingSingleton.getInstance());
    }
}
